import { Controller, Get } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { AppService } from './app.service';
import type { ApiResponse } from './common/interfaces/api-response.interface';

@Controller()
export class AppController {
  constructor(
    private readonly appService: AppService,
    private readonly configService: ConfigService,
  ) {}

  @Get()
  getHello(): ApiResponse<string> {
    return {
      success: true,
      data: this.appService.getHello(),
      message: '欢迎使用 WhatToEat API',
    };
  }

  @Get('health')
  getHealth(): ApiResponse<any> {
    return {
      success: true,
      data: {
        status: 'ok',
        timestamp: new Date().toISOString(),
        uptime: process.uptime(),
        environment: process.env.NODE_ENV || 'development',
        version: this.configService.get<string>('app.version', '1.0.0'),
      },
      message: '服务运行正常',
    };
  }

  @Get('info')
  getInfo(): ApiResponse<any> {
    return {
      success: true,
      data: {
        name: this.configService.get<string>('app.name', 'WhatToEat API'),
        version: this.configService.get<string>('app.version', '1.0.0'),
        description: '随机选择餐厅的API服务',
        author: 'WhatToEat Team',
        endpoints: {
          restaurants: '/api/restaurants',
          draw: '/api/draw',
          marks: '/api/marks',
          health: '/api/health',
        },
      },
      message: '应用信息获取成功',
    };
  }
}
